Git Product home page Git Product logo

fontmaps's Introduction

fontmaps

Mappings for non-Unicode fonts to Unicode

What is a fontmap?

A fontmap defines a relation from one encoding to another for each character in the initial font.
In our case, the characters come from non-unicode-encodings and should be translated to unicode.

Here is an example why a fontmap is needed:
For the greek character "phi", there exists variations of notation: ฯ†, U+03C6 and ฯ•, U+03D5.
In Mathtype Equation Format, the character can be saved with the MTCode/Unicode U+03D5, but be displayed with a font that makes it look like U+03C6. (Symbol font, font-position 6A, according to http://www.dessci.com/en/support/mathtype/tech/encodings/symbol.htm)
Since the meaning of both phi could differ, it is necessary that the symbol that looks like U+03C6 really IS the unicode-character U+03C6.
A fontmap for the font 'Symbol' will take the character with font-position 6A and output the character U+03C6.

How to get a fontmap?

Find it somewhere

This repository contains some fontmaps for common fonts like 'Symbol' or 'Wingdings'.
If none is available, it must be created (see below), and should be put here for others to use.

Create it

This is the part taking the longest time.
Fortunately once finished, fontmaps can be reused for all documents using the font.
For each character in your font, you repeat these steps:

  1. Find a suiting unicode character.
  2. Create an entry in the fontmap for your font.

There are 3 cases when initally mapping a character:

  1. The original encoding and unicode-position are identical, nothing needs to be done.
  2. There exists an identical looking unicode-character, you can directly map it.
  3. There is no identical looking unicode-character. In this case, you have to decide which unicode-character would be the best substitute in your situation. (This is the most tricky part)

You can take a look at the docx2hub/fontmaps for sample mappings.

A fontmap consists of an element <symbols>.
The name of the font will be solved in this order until one is matched: If there is an attribute 'mathtype-name', it is the font-name (Example: "Symbol", name as displayed in the font selector)
If there is an attribute 'docx-name', it is the font-name.
Else the font-name is extracted from the file-name(its base-uri()), where _ are replaced by spaces.
Thus, the file Mathype_MTCode.xml will be recognized as font-name 'Mathtype MTCode' if there are no attributes set in the file.
The child-elements are named <symbol>, each containing only attributes

  • attribute number: the font-position with 4 digits, left-padded with zero's (Example: "006A" for phi)
  • attribute char: the char as a numeric entity (Example: "&#x3c6;")

What happens when no fontmapping is available for a character?

There are several outcomes when a concrete mapping is missing:
The character will be likely output with his font-codepoint misinterpreted as unicode.
It may lead to varying appearance (like in the example with phi), may severely differ from the input or be in a unicode region which is not displayable (unicode private use area).

What happens when multiple fontmaps for the same font are loaded?

Custom-font-maps from users have precedence. When multiple fontmaps for the same font are provided by the custom-font-maps input port, the last of them is used. To override a default fontmap from docx2hub, you can simply provide your custom one.
There is no way to partially override only a single symbol, when providing a custom font map it is exclusively used.

fontmaps's People

Contributors

gimsieke avatar lwittmar avatar mkraetke avatar pglatza avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.