Browse Source

Refining font engine interface.

Michael Ragazzon 6 years ago
parent
commit
1bbae6380d

+ 0 - 4
Include/RmlUi/Core/ElementUtilities.h

@@ -77,10 +77,6 @@ public:
 	/// @param[in] tag Class name to search for.
 	static void GetElementsByClassName(ElementList& elements, Element* root_element, const String& class_name);
 
-	/// Returns an element's font face.
-	/// @param[in] element The element to determine the font face for.
-	/// @return The element's font face. This will be nullptr if no valid RCSS font styles have been set up for this element.
-	static FontFaceHandle GetFontFaceHandle(const Style::ComputedValues& computed_values);
 	/// Returns an element's density-independent pixel ratio, defined by it's context
 	/// @param[in] element The element to determine the density-independent pixel ratio for.
 	/// @return The density-independent pixel ratio of the context, or 1.0 if no context assigned.

+ 20 - 28
Include/RmlUi/Core/FontEngineInterface.h

@@ -41,13 +41,13 @@ public:
 	FontEngineInterface();
 	virtual ~FontEngineInterface();
 
-	/// Called by the RmlUi when it wants to load a font face from file.
+	/// Called by RmlUi when it wants to load a font face from file.
 	/// @param[in] file_name The file to load the face from.
 	/// @param[in] fallback_face True to use this font face for unknown characters in other font faces.
 	/// @return True if the face was loaded successfully, false otherwise.
 	virtual bool LoadFontFace(const String& file_name, bool fallback_face);
 
-	/// Called by the RmlUi when it wants to load a font face from memory, registered using the provided family, style, and weight.
+	/// Called by RmlUi when it wants to load a font face from memory, registered using the provided family, style, and weight.
 	/// @param[in] data A pointer to the data.
 	/// @param[in] data_size Size of the data in bytes.
 	/// @param[in] family The family to register the font as.
@@ -58,30 +58,22 @@ public:
 	/// Note: The debugger plugin will load its embedded font faces through this method using the family name 'rmlui-debugger-font'.
 	virtual bool LoadFontFace(const byte* data, int data_size, const String& family, Style::FontStyle style, Style::FontWeight weight, bool fallback_face);
 
-	/// Called by the RmlUi when a font configuration is resolved for an element. Should return a handle that 
-	/// can later be used to resolve properties of the face, and generate strings which can later be rendered.
+	/// Called by RmlUi when a font configuration is resolved for an element. Should return a handle that 
+	/// can later be used to resolve properties of the face, and generate string geometry to be rendered.
 	/// @param[in] family The family of the desired font handle.
 	/// @param[in] style The style of the desired font handle.
 	/// @param[in] weight The weight of the desired font handle.
-	/// @param[in] size The size of desired handle, in points. // TODO: Pixels?
+	/// @param[in] size The size of desired handle, in points.
 	/// @return A valid handle if a matching (or closely matching) font face was found, NULL otherwise.
 	virtual FontFaceHandle GetFontFaceHandle(const String& family, Style::FontStyle style, Style::FontWeight weight, int size);
 
-	/// Called by RmlUi when it wants to configure the layers such that font effects can be applied.
-	/// If font effects are not needed, it should return zero.
+	/// Called by RmlUi when a list of font effects is resolved for an element with a given font face.
 	/// @param[in] handle The font handle.
 	/// @param[in] font_effects The list of font effects to generate the configuration for.
-	/// @return The index to use when generating geometry using this configuration.
-	// TODO: Should return a handle.
-	virtual int GenerateLayerConfiguration(FontFaceHandle handle, const FontEffectList &font_effects);
+	/// @return A handle to the prepared font effects which will be used when generating geometry for a string.
+	virtual FontEffectsHandle PrepareFontEffects(FontFaceHandle handle, const FontEffectList &font_effects);
 
-	/// Should return the average advance of all glyphs in this font face.
-	/// @param[in] handle The font handle.
-	/// @return An approximate width of the characters in this font face.
-	// TODO: Not used, remove?
-	virtual int GetCharacterWidth(FontFaceHandle handle);
-
-	/// Should returns the point size of this font face.
+	/// Should return the point size of this font face.
 	/// @param[in] handle The font handle.
 	/// @return The face's point size.
 	virtual int GetSize(FontFaceHandle handle);
@@ -101,9 +93,9 @@ public:
 
 	/// Should return the font's underline, as a pixel offset from the bottom of the font.
 	/// @param[in] handle The font handle.
-	/// @return The font's underline thickness.
-	// TODO: Thickness vs Return value? Pointer?
-	virtual float GetUnderline(FontFaceHandle handle, float *thickness);
+	/// @param[out] thickness The font's underline thickness in pixels.
+	/// @return The underline pixel offset.
+	virtual float GetUnderline(FontFaceHandle handle, float &thickness);
 
 	/// Called by RmlUi when it wants to retrieve the width of a string when rendered with this handle.
 	/// @param[in] handle The font handle.
@@ -113,20 +105,20 @@ public:
 	virtual int GetStringWidth(FontFaceHandle handle, const String& string, CodePoint prior_character = CodePoint::Null);
 
 	/// Called by RmlUi when it wants to retrieve the geometry required to render a single line of text.
-	/// @param[in] handle The font handle.
-	/// @param[out] geometry An array of geometries to generate the geometry into.
-	/// @param[in] handle The font handle.
+	/// @param[in] face_handle The font handle.
+	/// @param[in] font_effects_handle The handle to the prepared font effects for which the geometry should be generated.
 	/// @param[in] string The string to render.
 	/// @param[in] position The position of the baseline of the first character to render.
 	/// @param[in] colour The colour to render the text.
-	/// @param[in] layer_configuration The layer for which the geometry should be generated.
+	/// @param[out] geometry An array of geometries to generate the geometry into.
 	/// @return The width, in pixels, of the string geometry.
-	// TODO: Layer configuration should be a handle. Reorder arguments to take the handles first, geometry last/first.
-	virtual int GenerateString(FontFaceHandle handle, GeometryList& geometry, const String& string, const Vector2f& position, const Colourb& colour, int layer_configuration);
+	virtual int GenerateString(FontFaceHandle face_handle, FontEffectsHandle font_effects_handle, const String& string, const Vector2f& position, const Colourb& colour, GeometryList& geometry);
 
-	/// Should return a new value whenever the geometry need to be re-generated.
+	/// Called by RmlUi to determine if the text geometry is required to be re-generated. Whenever the returned version
+	/// is changed, all geometry belonging to the given face handle will be re-generated.
+	/// @param[in] face_handle The font handle.
+	/// @return The version required for using the geometry.
 	virtual int GetVersion(FontFaceHandle handle);
-
 };
 
 }

+ 1 - 0
Include/RmlUi/Core/Types.h

@@ -113,6 +113,7 @@ using TextureHandle = uintptr_t;
 using CompiledGeometryHandle = uintptr_t;
 using DecoratorDataHandle = uintptr_t;
 using FontFaceHandle = uintptr_t;
+using FontEffectsHandle = uintptr_t;
 
 // Strings
 using String = std::string;

+ 10 - 11
Samples/basic/demo/data/demo.rml

@@ -116,9 +116,9 @@ button:focus {
 {
 	decorator: ninepatch(button-active, button-inner-active);
 }
-.emoji-test
+p.emojis
 {
-	/*font-family: Noto Emoji;*/
+	text-align: left;
 	font-size: 35px;
 	color: #b33;
 }
@@ -136,10 +136,14 @@ textarea {
 
 <div style="font-size: 0.85em; text-align: left;" id="fps"></div>
 
-<p class="font-test"><br/><br/>abc Å (æø 😍 å∞) Å def</p>
-<p class="emoji-test">abc 😍 def</p>
-
 <tabset id="menu">
+<tab>Welcome</tab>
+<panel id="welcome">
+	<p class="emojis">RmlUi 😍</p>
+	<p>Have fun fiddling about in this (incomplete) demo.</p>
+	<p>Press 'F8' to open up the debugger.</p>
+	<p class="emojis" style="margin-top: 1em;">🎉</p>
+</panel>
 <tab>Decorators</tab>
 <panel id="decorators">
 	<p>Image vs ninepatch decorator:</p>
@@ -171,12 +175,7 @@ textarea {
 <tab>Controls</tab>
 <panel>
 	<div>Type something here: <input style="vertical-align: -7px;" size="10" type="text" maxlength="12" value="Sample text"/></div>
-	<textarea cols="30" rows="5" wrap="nowrap">Hello World! dfd dsfds fdsfdf 
-sdfdfds d,. sfdsf. Heøøllo! Who are you? (I don't know),
-maybe there is åsomething å here??? dsfsdfsdf dfsd
-sd sad sads
-
-as</textarea>
+	<textarea cols="30" rows="5" wrap="nowrap">😍 Hello 🌐 World! 😎</textarea>
 </panel>
 </tabset>
 </body>

+ 4 - 1
Source/Core/ElementStyle.cpp

@@ -868,7 +868,10 @@ PropertyIdSet ElementStyle::ComputeValues(Style::ComputedValues& values, const S
 
 	// The font-face handle is nulled when local font properties are set. In that case we need to retrieve a new handle.
 	if (!values.font_face_handle)
-		values.font_face_handle = ElementUtilities::GetFontFaceHandle(values);
+	{
+		RMLUI_ZoneScopedN("FontFaceHandle");
+		values.font_face_handle = GetFontEngineInterface()->GetFontFaceHandle(values.font_family, values.font_style, values.font_weight, (int)values.font_size);
+	}
 
 	// Next, pass inheritable dirty properties onto our children
 	PropertyIdSet dirty_inherited_properties = (dirty_properties & StyleSheetSpecification::GetRegisteredInheritedProperties());

+ 17 - 18
Source/Core/ElementTextDefault.cpp

@@ -51,8 +51,8 @@ ElementTextDefault::ElementTextDefault(const String& tag) : ElementText(tag), co
 
 	geometry_dirty = true;
 
-	font_configuration = -1;
-	font_dirty = true;
+	font_effects_handle = 0;
+	font_effects_dirty = true;
 	font_handle_version = 0;
 }
 
@@ -84,12 +84,11 @@ void ElementTextDefault::OnRender()
 	if (font_face_handle == 0)
 		return;
 	
-	// If our font configuration has potentially changed, update it and force a geometry
-	// generation if necessary.
-	if (font_dirty && UpdateFontConfiguration())
+	// If our font effects have potentially changed, update it and force a geometry generation if necessary.
+	if (font_effects_dirty && UpdateFontEffects())
 		geometry_dirty = true;
 
-	// Dirty geometry if font version has changed
+	// Dirty geometry if font version has changed.
 	int new_version = GetFontEngineInterface()->GetVersion(font_face_handle);
 	if (new_version != font_handle_version)
 	{
@@ -276,8 +275,8 @@ void ElementTextDefault::AddLine(const Vector2f& line_position, const String& li
 	if (font_face_handle == 0)
 		return;
 
-	if (font_dirty)
-		UpdateFontConfiguration();
+	if (font_effects_dirty)
+		UpdateFontEffects();
 
 	Vector2f baseline_position = line_position + Vector2f(0.0f, (float)GetFontEngineInterface()->GetLineHeight(font_face_handle) - GetFontEngineInterface()->GetBaseline(font_face_handle));
 	lines.push_back(Line(line, baseline_position));
@@ -321,7 +320,7 @@ void ElementTextDefault::OnPropertyChange(const PropertyIdSet& changed_propertie
 		font_face_changed = true;
 
 		geometry.clear();
-		font_dirty = true;
+		font_effects_dirty = true;
 	}
 
 	if (changed_properties.Contains(PropertyId::TextDecoration))
@@ -337,7 +336,7 @@ void ElementTextDefault::OnPropertyChange(const PropertyIdSet& changed_propertie
 				if (font_face_handle != 0)
 				{
 					for (size_t i = 0; i < lines.size(); ++i)
-						GenerateDecoration(font_face_handle, lines[i]);
+						GenerateLineDecoration(font_face_handle, lines[i]);
 				}
 
 				generated_decoration = decoration_property;
@@ -372,14 +371,14 @@ void ElementTextDefault::GetRML(String& content)
 }
 
 // Updates the configuration this element uses for its font.
-bool ElementTextDefault::UpdateFontConfiguration()
+bool ElementTextDefault::UpdateFontEffects()
 {
 	RMLUI_ZoneScoped;
 
 	if (GetFontFaceHandle() == 0)
 		return false;
 
-	font_dirty = false;
+	font_effects_dirty = false;
 
 	static const FontEffectList empty_font_effects;
 
@@ -390,10 +389,10 @@ bool ElementTextDefault::UpdateFontConfiguration()
 
 	// Request a font layer configuration to match this set of effects. If this is different from
 	// our old configuration, then return true to indicate we'll need to regenerate geometry.
-	int new_configuration = GetFontEngineInterface()->GenerateLayerConfiguration(GetFontFaceHandle(), *font_effects);
-	if (new_configuration != font_configuration)
+	FontEffectsHandle new_font_effects_handle = GetFontEngineInterface()->PrepareFontEffects(GetFontFaceHandle(), *font_effects);
+	if (new_font_effects_handle != font_effects_handle)
 	{
-		font_configuration = new_configuration;
+		font_effects_handle = new_font_effects_handle;
 		return true;
 	}
 
@@ -418,16 +417,16 @@ void ElementTextDefault::GenerateGeometry(const FontFaceHandle font_face_handle)
 
 void ElementTextDefault::GenerateGeometry(const FontFaceHandle font_face_handle, Line& line)
 {
-	line.width = GetFontEngineInterface()->GenerateString(font_face_handle, geometry, line.text, line.position, colour, font_configuration);
+	line.width = GetFontEngineInterface()->GenerateString(font_face_handle, font_effects_handle, line.text, line.position, colour, geometry);
 	for (size_t i = 0; i < geometry.size(); ++i)
 		geometry[i].SetHostElement(this);
 
 	if (decoration_property != Style::TextDecoration::None)
-		GenerateDecoration(font_face_handle, line);
+		GenerateLineDecoration(font_face_handle, line);
 }
 
 // Generates any geometry necessary for rendering a line decoration (underline, strike-through, etc).
-void ElementTextDefault::GenerateDecoration(const FontFaceHandle font_face_handle, const Line& line)
+void ElementTextDefault::GenerateLineDecoration(const FontFaceHandle font_face_handle, const Line& line)
 {
 	RMLUI_ZoneScopedC(0xA52A2A);
 	

+ 7 - 11
Source/Core/ElementTextDefault.h

@@ -85,18 +85,13 @@ protected:
 	void GetRML(String& content) override;
 
 private:
-	// Updates the configuration this element uses for its font, depending on which font effects
-	// are active.
-	bool UpdateFontConfiguration();
+	// Prepares the font effects this element uses for its font.
+	bool UpdateFontEffects();
 
 	// Used to store the position and length of each line we have geometry for.
 	struct Line
 	{
-		Line(const String& text, const Vector2f& position) : text(text), position(position)
-		{
-			width = 0;
-		}
-
+		Line(const String& text, const Vector2f& position) : text(text), position(position), width(0) {}
 		String text;
 		Vector2f position;
 		int width;
@@ -107,7 +102,7 @@ private:
 	// Generates the geometry for a single line of text.
 	void GenerateGeometry(const FontFaceHandle font_face_handle, Line& line);
 	// Generates any geometry necessary for rendering a line decoration (underline, strike-through, etc).
-	void GenerateDecoration(const FontFaceHandle font_face_handle, const Line& line);
+	void GenerateLineDecoration(const FontFaceHandle font_face_handle, const Line& line);
 
 	String text;
 
@@ -130,9 +125,10 @@ private:
 	// it isn't being changed.
 	Style::TextDecoration decoration_property;
 
-	int font_configuration;
+	FontEffectsHandle font_effects_handle;
+	bool font_effects_dirty;
+
 	int font_handle_version;
-	bool font_dirty;
 };
 
 }

+ 0 - 10
Source/Core/ElementUtilities.cpp

@@ -138,16 +138,6 @@ void ElementUtilities::GetElementsByClassName(ElementList& elements, Element* ro
 	}
 }
 
-// Returns the element's font face.
-FontFaceHandle ElementUtilities::GetFontFaceHandle(const Style::ComputedValues& computed_values)
-{
-	RMLUI_ZoneScoped;
-	
-	int font_size = (int)computed_values.font_size;
-
-	return GetFontEngineInterface()->GetFontFaceHandle(computed_values.font_family, computed_values.font_style, computed_values.font_weight, font_size);
-}
-
 float ElementUtilities::GetDensityIndependentPixelRatio(Element * element)
 {
 	Context* context = element->GetContext();

+ 5 - 11
Source/Core/FontEngineInterface.cpp

@@ -59,12 +59,7 @@ FontFaceHandle FontEngineInterface::GetFontFaceHandle(const String& RMLUI_UNUSED
 	return 0;
 }
 	
-int FontEngineInterface::GenerateLayerConfiguration(FontFaceHandle, const FontEffectList& font_effects)
-{
-	return 0;
-}
-
-int FontEngineInterface::GetCharacterWidth(FontFaceHandle)
+FontEffectsHandle FontEngineInterface::PrepareFontEffects(FontFaceHandle, const FontEffectList& font_effects)
 {
 	return 0;
 }
@@ -89,7 +84,7 @@ int FontEngineInterface::GetBaseline(FontFaceHandle)
 	return 0;
 }
 
-float FontEngineInterface::GetUnderline(FontFaceHandle, float *)
+float FontEngineInterface::GetUnderline(FontFaceHandle, float &)
 {
 	return 0;
 }
@@ -101,14 +96,13 @@ int FontEngineInterface::GetStringWidth(FontFaceHandle, const String& RMLUI_UNUS
 	return 0;
 }
 
-int FontEngineInterface::GenerateString(FontFaceHandle, GeometryList& RMLUI_UNUSED_PARAMETER(geometry), const String& RMLUI_UNUSED_PARAMETER(string), 
-	const Vector2f& RMLUI_UNUSED_PARAMETER(position), const Colourb& RMLUI_UNUSED_PARAMETER(colour), int RMLUI_UNUSED_PARAMETER(layer_configuration))
+int FontEngineInterface::GenerateString(FontFaceHandle, FontEffectsHandle, const String& RMLUI_UNUSED_PARAMETER(string),
+	const Vector2f& RMLUI_UNUSED_PARAMETER(position), const Colourb& RMLUI_UNUSED_PARAMETER(colour), GeometryList& RMLUI_UNUSED_PARAMETER(geometry))
 {
-	RMLUI_UNUSED(geometry);
 	RMLUI_UNUSED(string);
 	RMLUI_UNUSED(position);
 	RMLUI_UNUSED(colour);
-	RMLUI_UNUSED(layer_configuration);
+	RMLUI_UNUSED(geometry);
 	return 0;
 }
 

+ 6 - 12
Source/Core/FontEngineInterfaceDefault.cpp

@@ -62,16 +62,10 @@ FontFaceHandle FontEngineInterfaceDefault::GetFontFaceHandle(const String& famil
 	return reinterpret_cast<FontFaceHandle>(handle.get());
 }
 	
-int FontEngineInterfaceDefault::GenerateLayerConfiguration(FontFaceHandle handle, const FontEffectList& font_effects)
+FontEffectsHandle FontEngineInterfaceDefault::PrepareFontEffects(FontFaceHandle handle, const FontEffectList& font_effects)
 {
 	auto handle_default = reinterpret_cast<FontFaceHandleDefault *>(handle);
-	return handle_default->GenerateLayerConfiguration(font_effects);
-}
-
-int FontEngineInterfaceDefault::GetCharacterWidth(FontFaceHandle handle)
-{
-	auto handle_default = reinterpret_cast<FontFaceHandleDefault *>(handle);
-	return handle_default->GetCharacterWidth();
+	return (FontEffectsHandle)handle_default->GenerateLayerConfiguration(font_effects);
 }
 
 int FontEngineInterfaceDefault::GetSize(FontFaceHandle handle)
@@ -98,7 +92,7 @@ int FontEngineInterfaceDefault::GetBaseline(FontFaceHandle handle)
 	return handle_default->GetBaseline();
 }
 
-float FontEngineInterfaceDefault::GetUnderline(FontFaceHandle handle, float *thickness)
+float FontEngineInterfaceDefault::GetUnderline(FontFaceHandle handle, float& thickness)
 {
 	auto handle_default = reinterpret_cast<FontFaceHandleDefault *>(handle);
 	return handle_default->GetUnderline(thickness);
@@ -110,11 +104,11 @@ int FontEngineInterfaceDefault::GetStringWidth(FontFaceHandle handle, const Stri
 	return handle_default->GetStringWidth(string, prior_character);
 }
 
-int FontEngineInterfaceDefault::GenerateString(FontFaceHandle handle, GeometryList& geometry, const String& string,
-	const Vector2f& position, const Colourb& colour, int layer_configuration)
+int FontEngineInterfaceDefault::GenerateString(FontFaceHandle handle, FontEffectsHandle font_effects_handle, const String& string,
+	const Vector2f& position, const Colourb& colour, GeometryList& geometry)
 {
 	auto handle_default = reinterpret_cast<FontFaceHandleDefault *>(handle);
-	return handle_default->GenerateString(geometry, string, position, colour, layer_configuration);
+	return handle_default->GenerateString(geometry, string, position, colour, (int)font_effects_handle);
 }
 
 int FontEngineInterfaceDefault::GetVersion(FontFaceHandle handle)

+ 5 - 7
Source/Core/FontEngineInterfaceDefault.h

@@ -50,11 +50,8 @@ public:
 	/// valid handle.
 	FontFaceHandle GetFontFaceHandle(const String& family, Style::FontStyle style, Style::FontWeight weight, int size) override;
 
-	/// Generates, if required, the layer configuration for a given array of font effects.
-	int GenerateLayerConfiguration(FontFaceHandle, const FontEffectList& font_effects) override;
-
-	/// Returns the average advance of all glyphs in this font face.
-	int GetCharacterWidth(FontFaceHandle) override;
+	/// Prepares for font effects by configuring a new, or returning an existing, layer configuration.
+	FontEffectsHandle PrepareFontEffects(FontFaceHandle, const FontEffectList& font_effects) override;
 
 	/// Returns the point size of this font face.
 	int GetSize(FontFaceHandle) override;
@@ -67,14 +64,15 @@ public:
 	int GetBaseline(FontFaceHandle) override;
 
 	/// Returns the font's underline, as a pixel offset from the bottom of the font.
-	float GetUnderline(FontFaceHandle, float* thickness) override;
+	float GetUnderline(FontFaceHandle, float& thickness) override;
 
 	/// Returns the width a string will take up if rendered with this handle.
 	int GetStringWidth(FontFaceHandle, const String& string, CodePoint prior_character) override;
 
 	/// Generates the geometry required to render a single line of text.
-	int GenerateString(FontFaceHandle, GeometryList& geometry, const String& string, const Vector2f& position, const Colourb& colour, int layer_configuration) override;
+	int GenerateString(FontFaceHandle, FontEffectsHandle, const String& string, const Vector2f& position, const Colourb& colour, GeometryList& geometry) override;
 
+	/// Returns the current version of the font face.
 	int GetVersion(FontFaceHandle handle) override;
 };
 

+ 2 - 10
Source/Core/FontFaceHandleDefault.cpp

@@ -57,12 +57,6 @@ int FontFaceHandleDefault::GetSize() const
 	return metrics.size;
 }
 
-// Returns the average advance of all glyphs in this font face.
-int FontFaceHandleDefault::GetCharacterWidth() const
-{
-	return metrics.average_advance;
-}
-
 // Returns the pixel height of a lower-case x in this font face.
 int FontFaceHandleDefault::GetXHeight() const
 {
@@ -87,11 +81,9 @@ const FontGlyphMap& FontFaceHandleDefault::GetGlyphs() const
 	return glyphs;
 }
 
-float FontFaceHandleDefault::GetUnderline(float *thickness) const
+float FontFaceHandleDefault::GetUnderline(float& thickness) const
 {
-	if (thickness != nullptr) {
-		*thickness = metrics.underline_thickness;
-	}
+	thickness = metrics.underline_thickness;
 	return metrics.underline_position;
 }
 

+ 6 - 19
Source/Core/FontFaceHandleDefault.h

@@ -42,14 +42,7 @@ namespace Core {
 
 class FontFaceLayer;
 
-/**
-	@author Peter Curry
- */
-
 struct FontMetrics {
-	// The average advance (in pixels) of all of this face's glyphs.
-	int average_advance;
-
 	int size;
 	int x_height;
 	int line_height;
@@ -59,36 +52,30 @@ struct FontMetrics {
 	float underline_thickness;
 };
 
+/**
+	@author Peter Curry
+ */
+
 class FontFaceHandleDefault : public NonCopyMoveable
 {
 public:
 	FontFaceHandleDefault();
 	virtual ~FontFaceHandleDefault();
 
-	/// Returns the average advance of all glyphs in this font face.
-	/// @return An approximate width of the characters in this font face.
-	int GetCharacterWidth() const;
-
 	/// Returns the point size of this font face.
-	/// @return The face's point size.
 	int GetSize() const;
 	/// Returns the pixel height of a lower-case x in this font face.
-	/// @return The height of a lower-case x.
 	int GetXHeight() const;
 	/// Returns the default height between this font face's baselines.
-	/// @return The default line height.
 	int GetLineHeight() const;
 
 	/// Returns the font's baseline, as a pixel offset from the bottom of the font.
-	/// @return The font's baseline.
 	int GetBaseline() const;
 
 	/// Returns the font's underline, as a pixel offset from the bottom of the font.
-	/// @return The font's underline thickness.
-	float GetUnderline(float* thickness) const;
+	float GetUnderline(float& thickness) const;
 
 	/// Returns the font's glyphs.
-	/// @return The font's glyphs.
 	const FontGlyphMap& GetGlyphs() const;
 
 	/// Returns the width a string will take up if rendered with this handle.
@@ -97,7 +84,7 @@ public:
 	/// @return The width, in pixels, this string will occupy if rendered with this handle.
 	int GetStringWidth(const String& string, CodePoint prior_character = CodePoint::Null);
 
-	/// Generates, if required, the layer configuration for a given array of font effects.
+	/// Generates, if required, the layer configuration for a given list of font effects.
 	/// @param[in] font_effects The list of font effects to generate the configuration for.
 	/// @return The index to use when generating geometry using this configuration.
 	int GenerateLayerConfiguration(const FontEffectList& font_effects);

+ 0 - 16
Source/Core/FreeType/FontFaceHandle.cpp

@@ -270,22 +270,6 @@ static void GenerateMetrics(FT_Face ft_face, const FontGlyphMap& glyphs, FontMet
 	metrics.underline_thickness = FT_MulFix(ft_face->underline_thickness, ft_face->size->metrics.y_scale) / float(1 << 6);
 	metrics.underline_thickness = Math::Max(metrics.underline_thickness, 1.0f);
 
-	metrics.average_advance = 0;
-	unsigned int num_visible_glyphs = 0;
-	for (auto it = glyphs.begin(); it != glyphs.end(); ++it)
-	{
-		const FontGlyph& glyph = it->second;
-		if (glyph.advance)
-		{
-			metrics.average_advance += glyph.advance;
-			num_visible_glyphs++;
-		}
-	}
-
-	// Bring the total advance down to the average advance, but scaled up 10%, just to be on the safe side.
-	if (num_visible_glyphs)
-		metrics.average_advance = Math::RealToInteger((float)metrics.average_advance / (num_visible_glyphs * 0.9f));
-
 	// Determine the x-height of this font face.
 	int index = FT_Get_Char_Index(ft_face, 'x');
 	if (FT_Load_Glyph(ft_face, index, 0) == 0)

+ 2 - 2
Source/Core/GeometryUtilities.cpp

@@ -80,7 +80,7 @@ void GeometryUtilities::GenerateLine(FontFaceHandle font_face_handle, Geometry*
 	std::vector< Vertex >& line_vertices = geometry->GetVertices();
 	std::vector< int >& line_indices = geometry->GetIndices();
 	float underline_thickness = 0;
-	float underline_position = GetFontEngineInterface()->GetUnderline(font_face_handle, &underline_thickness);
+	float underline_position = GetFontEngineInterface()->GetUnderline(font_face_handle, underline_thickness);
 	int size = GetFontEngineInterface()->GetSize(font_face_handle);
 	int x_height = GetFontEngineInterface()->GetXHeight(font_face_handle);
 
@@ -89,7 +89,7 @@ void GeometryUtilities::GenerateLine(FontFaceHandle font_face_handle, Geometry*
 	{
 		case Style::TextDecoration::Underline:       offset = -underline_position; break;
 		case Style::TextDecoration::Overline:        offset = -underline_position - (float)size; break;
-		case Style::TextDecoration::LineThrough:     offset = -0.65f * (float)x_height; break; // or maybe: -underline_position - (float)size * 0.5f
+		case Style::TextDecoration::LineThrough:     offset = -0.65f * (float)x_height; break;
 		default: return;
 	}