diff options
author | Chris Loer <chris.loer@gmail.com> | 2017-11-28 15:33:19 -0800 |
---|---|---|
committer | Chris Loer <chris.loer@gmail.com> | 2017-11-28 15:33:19 -0800 |
commit | 3d7669bafd97cf0838d226eab8fa72bb977537cc (patch) | |
tree | 38b7f15137b736cd0016076d8e11f5757e7cdd62 | |
parent | bfefc93a3b1f9309f3b403d8a3bed36d62cc416d (diff) | |
download | qtlocation-mapboxgl-3d7669bafd97cf0838d226eab8fa72bb977537cc.tar.gz |
Fix unit tests.
-rw-r--r-- | platform/darwin/src/local_glyph_rasterizer.mm | 19 | ||||
-rw-r--r-- | platform/ios/config.cmake | 1 | ||||
-rw-r--r-- | platform/macos/config.cmake | 1 | ||||
-rw-r--r-- | src/mbgl/text/glyph_manager.hpp | 2 |
4 files changed, 15 insertions, 8 deletions
diff --git a/platform/darwin/src/local_glyph_rasterizer.mm b/platform/darwin/src/local_glyph_rasterizer.mm index f12be78daa..a5edecb097 100644 --- a/platform/darwin/src/local_glyph_rasterizer.mm +++ b/platform/darwin/src/local_glyph_rasterizer.mm @@ -22,16 +22,21 @@ namespace mbgl { */ using CTFontDescriptorRefHandle = CFHandle<CTFontDescriptorRef, CFTypeRef, CFRelease>; -using CTFontRefHandle = CFHandle<CTFontRef, CFTypeRef, CFRelease>; using CTLineRefHandle = CFHandle<CTLineRef, CFTypeRef, CFRelease>; class LocalGlyphRasterizer::Impl { public: - Impl(CTFontRef fontHandle) - : font(fontHandle) + Impl(CTFontRef font_) + : font(font_) {} + + ~Impl() { + if (font) { + CFRelease(font); + } + } - CTFontRefHandle font; + CTFontRef font; }; LocalGlyphRasterizer::LocalGlyphRasterizer(const optional<std::string> fontFamily) @@ -56,7 +61,7 @@ LocalGlyphRasterizer::~LocalGlyphRasterizer() bool LocalGlyphRasterizer::canRasterizeGlyph(const FontStack&, GlyphID glyphID) { // TODO: This is a rough approximation of the set of glyphs that will work with fixed glyph metrics // Either narrow this down to be conservative, or actually extract glyph metrics in rasterizeGlyph - return *(impl->font) && util::i18n::allowsIdeographicBreaking(glyphID); + return impl->font && util::i18n::allowsIdeographicBreaking(glyphID); } // TODO: In theory we should be able to transform user-coordinate bounding box and advance @@ -137,7 +142,7 @@ PremultipliedImage drawGlyphBitmap(GlyphID glyphID, CTFontRef font, Size size) { Glyph LocalGlyphRasterizer::rasterizeGlyph(const FontStack&, GlyphID glyphID) { Glyph fixedMetrics; - if (!*(impl->font)) { + if (!impl->font) { return fixedMetrics; } @@ -151,7 +156,7 @@ Glyph LocalGlyphRasterizer::rasterizeGlyph(const FontStack&, GlyphID glyphID) { fixedMetrics.metrics.top = -1; fixedMetrics.metrics.advance = 24; - PremultipliedImage rgbaBitmap = drawGlyphBitmap(glyphID, *(impl->font), size); + PremultipliedImage rgbaBitmap = drawGlyphBitmap(glyphID, impl->font, size); // Copy alpha values from RGBA bitmap into the AlphaImage output fixedMetrics.bitmap = AlphaImage(size); diff --git a/platform/ios/config.cmake b/platform/ios/config.cmake index 0cfc86d548..55de8bc398 100644 --- a/platform/ios/config.cmake +++ b/platform/ios/config.cmake @@ -85,6 +85,7 @@ macro(mbgl_platform_core) target_link_libraries(mbgl-core PUBLIC "-lz" PUBLIC "-framework Foundation" + PUBLIC "-framework CoreText" PUBLIC "-framework CoreGraphics" PUBLIC "-framework OpenGLES" PUBLIC "-framework ImageIO" diff --git a/platform/macos/config.cmake b/platform/macos/config.cmake index 8646a79071..a91719b9d4 100644 --- a/platform/macos/config.cmake +++ b/platform/macos/config.cmake @@ -65,6 +65,7 @@ macro(mbgl_platform_core) target_link_libraries(mbgl-core PUBLIC "-lz" PUBLIC "-framework Foundation" + PUBLIC "-framework CoreText" PUBLIC "-framework CoreGraphics" PUBLIC "-framework OpenGL" PUBLIC "-framework ImageIO" diff --git a/src/mbgl/text/glyph_manager.hpp b/src/mbgl/text/glyph_manager.hpp index d34ec2a61e..84db2c4be5 100644 --- a/src/mbgl/text/glyph_manager.hpp +++ b/src/mbgl/text/glyph_manager.hpp @@ -25,7 +25,7 @@ public: class GlyphManager : public util::noncopyable { public: - GlyphManager(FileSource&, std::unique_ptr<LocalGlyphRasterizer>); + GlyphManager(FileSource&, std::unique_ptr<LocalGlyphRasterizer> = std::make_unique<LocalGlyphRasterizer>(optional<std::string>())); ~GlyphManager(); // Workers send a `getGlyphs` message to the main thread once they have determined |