# mdefont

API documentation

More info on the mdefont wiki page.

## Important Functions

MDF_InitFont
  Creates an MDF_FontEngine instance and stores it in MdefontModule. This instance will be used as the default engine for functions that take an optional engine as an argument. MDF_ShutdownFont should be called before opera terminates. At this time, there should be no live MDE_FONT objects created with the engine.
MDF_ShutdownFont
  Destroys the instance created by MDF_InitFont
MDF_CreateFontEngine
  Create an MDF_FontEngine. Any number of font engines can be created. Caller obtains ownership, and should pass the engine to MDF_DestroyFontEngine when no longer needed, at which time there should be no live MDE_FONT objects created with the engine.
MDF_DestroyFontEngine
  Destroys an MDF_FontEngine created with MDF_CreateFontEngine.
MDF_AddFontFile
  Adds a font file to mdf.
MDF_GetFont
  Fetches a handle to a loaded font.
MDF_ReleaseFont
  Releases a font fetched with a call to MDF_GetFont
MDF_StringWidth
  Measures a string.
MDF_DrawString
  Draws a string - optional API:s provide drawing to an OpBitmap or MDE_BUFFER.

## On using several font engines

Typically only one font engine is needed. The mdefont API makes using one font engine easy by providing MDF_InitFont and MDF_ShutdownFont, along with the default value to functions that are passed an engine. As long as only one font engine is needed, users can simply ignore MDF_FontEngine completely. The default value to the engine parameter will always correspond to the engine created by MDF_InitFont.

However, some platforms have special needs. If more than one font engine is needed - eg one for the core process and one for the ui - MDF_CreateFontEngine can be used to create any number of engines. In order to use an engine created using MDF_CreateFontEngine the engine must be explicitly passed to the functions in the mdefont API taking an optional engine as argument. Note that created fonts automatically keep track of the engine to use.