Bläddra i källkod

Remove the 'font-charset' property

Michael Ragazzon 6 år sedan
förälder
incheckning
0ed3768644

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

@@ -171,7 +171,6 @@ struct ComputedValues
 	float opacity = 1;
 
 	String font_family;
-	String font_charset; // empty is same as "U+0020-007E"
 	FontStyle font_style = FontStyle::Normal;
 	FontWeight font_weight = FontWeight::Normal;
 	float font_size = 12.f;

+ 1 - 2
Include/RmlUi/Core/FontDatabase.h

@@ -82,12 +82,11 @@ public:
 	/// it can find, but in the event a font family is requested that does not exist, nullptr will be returned instead of a
 	/// valid handle.
 	/// @param[in] family The family of the desired font handle.
-	/// @param[in] charset The set of characters required in the font face, as a comma-separated list of unicode ranges.
 	/// @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.
 	/// @return A valid handle if a matching (or closely matching) font face was found, nullptr otherwise.
-	static SharedPtr<FontFaceHandle> GetFontFaceHandle(const String& family, const String& charset, Style::FontStyle style, Style::FontWeight weight, int size);
+	static SharedPtr<FontFaceHandle> GetFontFaceHandle(const String& family, Style::FontStyle style, Style::FontWeight weight, int size);
 
     static void AddFontProvider(FontProvider * provider);
 

+ 2 - 2
Include/RmlUi/Core/FontFace.h

@@ -54,7 +54,6 @@ public:
 	Style::FontWeight GetWeight() const;
 
 	/// Returns a handle for positioning and rendering this face at the given size.
-	/// @param[in] charset The set of characters in the handle, as a comma-separated list of unicode ranges.
 	/// @param[in] size The size of the desired handle, in points.
 	/// @return The shared font handle.
     virtual SharedPtr<FontFaceHandle> GetHandle(int size) = 0;
@@ -69,7 +68,8 @@ protected:
 
 	bool release_stream;
 
-	typedef UnorderedMap< int, SharedPtr<FontFaceHandle> > HandleMap;
+	// Key is font size
+	using HandleMap = UnorderedMap< int, SharedPtr<FontFaceHandle> >;
 	HandleMap handles;
 };
 

+ 1 - 2
Include/RmlUi/Core/FontFamily.h

@@ -56,12 +56,11 @@ public:
     virtual bool AddFace(void* ft_face, Style::FontStyle style, Style::FontWeight weight, bool release_stream) = 0;
 
 	/// Returns a handle to the most appropriate font in the family, at the correct size.
-	/// @param[in] charset The set of characters in the handle, as a comma-separated list of unicode ranges.
 	/// @param[in] style The style of the desired handle.
 	/// @param[in] weight The weight of the desired handle.
 	/// @param[in] size The size of desired handle, in points.
 	/// @return A valid handle if a matching (or closely matching) font face was found, nullptr otherwise.
-	SharedPtr<FontFaceHandle> GetFaceHandle(const String& charset, Style::FontStyle style, Style::FontWeight weight, int size);
+	SharedPtr<FontFaceHandle> GetFaceHandle(Style::FontStyle style, Style::FontWeight weight, int size);
 
 protected:
 	String name;

+ 1 - 2
Include/RmlUi/Core/FontProvider.h

@@ -52,12 +52,11 @@ public:
     /// it can find, but in the event a font family is requested that does not exist, nullptr will be returned instead of a
     /// valid handle.
     /// @param[in] family The family of the desired font handle.
-    /// @param[in] charset The set of characters required in the font face, as a comma-separated list of unicode ranges.
     /// @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.
     /// @return A valid handle if a matching (or closely matching) font face was found, nullptr otherwise.
-	SharedPtr<FontFaceHandle> GetFontFaceHandle(const String& family, const String& charset, Style::FontStyle style, Style::FontWeight weight, int size);
+	SharedPtr<FontFaceHandle> GetFontFaceHandle(const String& family, Style::FontStyle style, Style::FontWeight weight, int size);
 
 protected:
 

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

@@ -113,7 +113,6 @@ enum class PropertyId : uint16_t
 	Color,
 	ImageColor,
 	FontFamily,
-	FontCharset,
 	FontStyle,
 	FontWeight,
 	FontSize,

+ 0 - 5
Source/Core/ElementStyle.cpp

@@ -575,7 +575,6 @@ PropertyIdSet ElementStyle::ComputeValues(Style::ComputedValues& values, const S
 		values.opacity = parent_values->opacity;
 
 		values.font_family = parent_values->font_family;
-		values.font_charset = parent_values->font_charset;
 		values.font_style = parent_values->font_style;
 		values.font_weight = parent_values->font_weight;
 		values.font_face_handle = parent_values->font_face_handle;
@@ -747,10 +746,6 @@ PropertyIdSet ElementStyle::ComputeValues(Style::ComputedValues& values, const S
 			values.font_family = StringUtilities::ToLower(p->Get<String>());
 			values.font_face_handle.reset();
 			break;
-		case PropertyId::FontCharset:
-			values.font_charset = p->Get<String>();
-			values.font_face_handle.reset();
-			break;
 		case PropertyId::FontStyle:
 			values.font_style = (FontStyle)p->Get< int >();
 			values.font_face_handle.reset();

+ 0 - 1
Source/Core/ElementTextDefault.cpp

@@ -310,7 +310,6 @@ void ElementTextDefault::OnPropertyChange(const PropertyIdSet& changed_propertie
 	}
 
 	if (changed_properties.Contains(PropertyId::FontFamily) ||
-		changed_properties.Contains(PropertyId::FontCharset) ||
 		changed_properties.Contains(PropertyId::FontWeight) ||
 		changed_properties.Contains(PropertyId::FontStyle) ||
 		changed_properties.Contains(PropertyId::FontSize))

+ 2 - 5
Source/Core/ElementUtilities.cpp

@@ -142,13 +142,10 @@ void ElementUtilities::GetElementsByClassName(ElementList& elements, Element* ro
 SharedPtr<FontFaceHandle> ElementUtilities::GetFontFaceHandle(const Style::ComputedValues& computed_values)
 {
 	RMLUI_ZoneScoped;
-
-	static const String default_charset = "U+0020-007E";
-
-	const String& charset = (computed_values.font_charset.empty() ? default_charset : computed_values.font_charset);
+	
 	int font_size = (int)computed_values.font_size;
 
-	return FontDatabase::GetFontFaceHandle(computed_values.font_family, charset, computed_values.font_style, computed_values.font_weight, font_size);
+	return FontDatabase::GetFontFaceHandle(computed_values.font_family, computed_values.font_style, computed_values.font_weight, font_size);
 }
 
 float ElementUtilities::GetDensityIndependentPixelRatio(Element * element)

+ 2 - 2
Source/Core/FontDatabase.cpp

@@ -98,13 +98,13 @@ bool FontDatabase::LoadFontFace(const byte* data, int data_length, const String&
 }
 
 // Returns a handle to a font face that can be used to position and render text.
-SharedPtr<FontFaceHandle> FontDatabase::GetFontFaceHandle(const String& family, const String& charset, Style::FontStyle style, Style::FontWeight weight, int size)
+SharedPtr<FontFaceHandle> FontDatabase::GetFontFaceHandle(const String& family, Style::FontStyle style, Style::FontWeight weight, int size)
 {
     size_t provider_count = font_provider_table.size();
 
     for(size_t provider_index = 0; provider_index < provider_count; ++provider_index)
     {
-		SharedPtr<FontFaceHandle> face_handle = font_provider_table[ provider_index ]->GetFontFaceHandle(family, charset, style, weight, size);
+		SharedPtr<FontFaceHandle> face_handle = font_provider_table[ provider_index ]->GetFontFaceHandle(family, style, weight, size);
 
         if(face_handle)
             return face_handle;

+ 1 - 1
Source/Core/FontFamily.cpp

@@ -44,7 +44,7 @@ FontFamily::~FontFamily()
 }
 
 // Returns a handle to the most appropriate font in the family, at the correct size.
-SharedPtr<FontFaceHandle> FontFamily::GetFaceHandle(const String& charset, Style::FontStyle style, Style::FontWeight weight, int size)
+SharedPtr<FontFaceHandle> FontFamily::GetFaceHandle(Style::FontStyle style, Style::FontWeight weight, int size)
 {
 	// Search for a face of the same style, and match the weight as closely as we can.
 	FontFace* matching_face = nullptr;

+ 2 - 2
Source/Core/FontProvider.cpp

@@ -34,14 +34,14 @@ namespace Rml {
 namespace Core {
 
 // Returns a handle to a font face that can be used to position and render text.
-SharedPtr<FontFaceHandle> FontProvider::GetFontFaceHandle(const String& family, const String& charset, Style::FontStyle style, Style::FontWeight weight, int size)
+SharedPtr<FontFaceHandle> FontProvider::GetFontFaceHandle(const String& family, Style::FontStyle style, Style::FontWeight weight, int size)
 {
 	RMLUI_ASSERTMSG(family == StringUtilities::ToLower(family), "Font family name must be converted to lowercase before entering here.");
 	FontFamilyMap::iterator iterator = font_families.find(family);
 	if (iterator == font_families.end())
 		return nullptr;
 
-	return (*iterator).second->GetFaceHandle(charset, style, weight, size);
+	return (*iterator).second->GetFaceHandle(style, weight, size);
 }
 
 }

+ 0 - 1
Source/Core/FreeType/FontFace.h

@@ -49,7 +49,6 @@ public:
 	~FontFace_FreeType();
 
 	/// Returns a handle for positioning and rendering this face at the given size.
-	/// @param[in] charset The set of characters in the handle, as a comma-separated list of unicode ranges.
 	/// @param[in] size The size of the desired handle, in points.
 	/// @return The shared font handle.
 	SharedPtr<Rml::Core::FontFaceHandle> GetHandle(int size) override;

+ 1 - 1
Source/Core/FreeType/FontFaceHandle.cpp

@@ -65,7 +65,7 @@ bool FontFaceHandle_FreeType::Initialise(FT_Face ft_face, int size)
 		return false;
 	}
 
-	// Construct the list of the characters specified by the charset.
+	// Construct the initial list of glyphs.
 	BuildGlyphMap(ft_face, GetGlyphs());
 
 	// Generate the metrics for the handle.

+ 0 - 1
Source/Core/FreeType/FontFaceHandle.h

@@ -52,7 +52,6 @@ public:
 
 	/// Initialises the handle so it is able to render text.
 	/// @param[in] ft_face The FreeType face that this handle is rendering.
-	/// @param[in] charset The comma-separated list of unicode ranges this handle must support.
 	/// @param[in] size The size, in points, of the face this handle should render at.
 	/// @return True if the handle initialised successfully and is ready for rendering, false if an error occured.
 	bool Initialise(FT_Face ft_face, int size);

+ 0 - 1
Source/Core/StringCache.cpp

@@ -83,7 +83,6 @@ const String BACKGROUND = "background";
 const String COLOR = "color";
 const String IMAGE_COLOR = "image-color";
 const String FONT_FAMILY = "font-family";
-const String FONT_CHARSET = "font-charset";
 const String FONT_STYLE = "font-style";
 const String FONT_WEIGHT = "font-weight";
 const String FONT_SIZE = "font-size";

+ 1 - 2
Source/Core/StyleSheetSpecification.cpp

@@ -333,11 +333,10 @@ void StyleSheetSpecification::RegisterDefaultProperties()
 	RegisterProperty(PropertyId::Opacity, OPACITY, "1", true, false).AddParser("number");
 
 	RegisterProperty(PropertyId::FontFamily, FONT_FAMILY, "", true, true).AddParser("string");
-	RegisterProperty(PropertyId::FontCharset, FONT_CHARSET, "U+0020-007E", true, false).AddParser("string");
 	RegisterProperty(PropertyId::FontStyle, FONT_STYLE, "normal", true, true).AddParser("keyword", "normal, italic");
 	RegisterProperty(PropertyId::FontWeight, FONT_WEIGHT, "normal", true, true).AddParser("keyword", "normal, bold");
 	RegisterProperty(PropertyId::FontSize, FONT_SIZE, "12px", true, true).AddParser("length").AddParser("length_percent").SetRelativeTarget(RelativeTarget::ParentFontSize);
-	RegisterShorthand(ShorthandId::Font, FONT, "font-style, font-weight, font-size, font-family, font-charset", ShorthandType::FallThrough);
+	RegisterShorthand(ShorthandId::Font, FONT, "font-style, font-weight, font-size, font-family", ShorthandType::FallThrough);
 
 	RegisterProperty(PropertyId::TextAlign, TEXT_ALIGN, LEFT, true, true).AddParser("keyword", "left, right, center, justify");
 	RegisterProperty(PropertyId::TextDecoration, TEXT_DECORATION, "none", true, false).AddParser("keyword", "none, underline, overline, line-through");