Title: [295038] trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp
- Revision
- 295038
- Author
- [email protected]
- Date
- 2022-05-30 16:59:45 -0700 (Mon, 30 May 2022)
Log Message
[Cocoa] Rename [de]normalizeWeight() to [de]normalizeGXWeight()
https://bugs.webkit.org/show_bug.cgi?id=241112
Reviewed by Alan Bujtas.
Weights are measured in 3 different scales:
1. CSS weights (1 - 999)
2. Core Text weights (-1.0 - 1.0)
3. TrueType GX weights (0.0ish to 2.0ish, it's not really defined, only the "default" value
of 1.0 is defined).
Our current functions convert between CSS weights and TrueType GX weights, so this makes that more
clear. A subsequent patch will add conversions between CSS weights and Core Text weights.
No new tests because there is no behavior change.
* Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp:
(WebCore::normalizeGXWeight):
(WebCore::denormalizeGXWeight):
(WebCore::preparePlatformFont):
(WebCore::variationCapabilitiesForFontDescriptor):
(WebCore::normalizeWeight): Deleted.
(WebCore::denormalizeWeight): Deleted.
Canonical link: https://commits.webkit.org/251132@main
Modified Paths
Diff
Modified: trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp (295037 => 295038)
--- trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp 2022-05-30 23:58:55 UTC (rev 295037)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp 2022-05-30 23:59:45 UTC (rev 295038)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2015-2021 Apple Inc. All rights reserved.
+ * Copyright (C) 2015-2022 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -364,7 +364,7 @@
// These values were calculated by performing a linear regression on the CSS weights/widths/slopes and Core Text weights/widths/slopes of San Francisco.
// FIXME: <rdar://problem/31312602> Get the real values from Core Text.
-static inline float normalizeWeight(float value)
+static inline float normalizeGXWeight(float value)
{
return 523.7 * value - 109.3;
}
@@ -374,7 +374,7 @@
return value * 300;
}
-static inline float denormalizeWeight(float value)
+static inline float denormalizeGXWeight(float value)
{
return (value + 109.3) / 523.7;
}
@@ -605,7 +605,7 @@
if (auto slopeValue = fontCreationContext.fontFaceCapabilities().weight)
slope = std::max(std::min(slope, static_cast<float>(slopeValue->maximum)), static_cast<float>(slopeValue->minimum));
if (needsConversion) {
- weight = denormalizeWeight(weight);
+ weight = denormalizeGXWeight(weight);
width = denormalizeVariationWidth(width);
slope = denormalizeSlope(slope);
}
@@ -1064,7 +1064,7 @@
if (FontType(font.get()).variationType == FontType::VariationType::TrueTypeGX && !optOutFromGXNormalization) {
if (result.weight)
- result.weight = { { normalizeWeight(result.weight.value().minimum), normalizeWeight(result.weight.value().maximum) } };
+ result.weight = { { normalizeGXWeight(result.weight.value().minimum), normalizeGXWeight(result.weight.value().maximum) } };
if (result.width)
result.width = { { normalizeVariationWidth(result.width.value().minimum), normalizeVariationWidth(result.width.value().maximum) } };
if (result.slope)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes