[core] Hook LocalGlyphRasterizer "font family" configuration up to Renderer
This commit is contained in:
@@ -25,7 +25,8 @@ class Renderer {
|
||||
public:
|
||||
Renderer(RendererBackend&, float pixelRatio_, FileSource&, Scheduler&,
|
||||
GLContextMode = GLContextMode::Unique,
|
||||
const optional<std::string> programCacheDir = {});
|
||||
const optional<std::string> programCacheDir = {},
|
||||
const optional<std::string> localFontFamily = {});
|
||||
~Renderer();
|
||||
|
||||
void markContextLost();
|
||||
|
||||
@@ -2,6 +2,15 @@
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
class LocalGlyphRasterizer::Impl {
|
||||
};
|
||||
|
||||
LocalGlyphRasterizer::LocalGlyphRasterizer(const optional<std::string>)
|
||||
{}
|
||||
|
||||
LocalGlyphRasterizer::~LocalGlyphRasterizer()
|
||||
{}
|
||||
|
||||
bool LocalGlyphRasterizer::canRasterizeGlyph(const FontStack&, GlyphID) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -10,9 +10,10 @@ Renderer::Renderer(RendererBackend& backend,
|
||||
FileSource& fileSource_,
|
||||
Scheduler& scheduler_,
|
||||
GLContextMode contextMode_,
|
||||
const optional<std::string> programCacheDir_)
|
||||
const optional<std::string> programCacheDir_,
|
||||
const optional<std::string> localFontFamily_)
|
||||
: impl(std::make_unique<Impl>(backend, pixelRatio_, fileSource_, scheduler_,
|
||||
contextMode_, std::move(programCacheDir_))) {
|
||||
contextMode_, std::move(programCacheDir_), std::move(localFontFamily_))) {
|
||||
}
|
||||
|
||||
Renderer::~Renderer() {
|
||||
|
||||
@@ -42,7 +42,8 @@ Renderer::Impl::Impl(RendererBackend& backend_,
|
||||
FileSource& fileSource_,
|
||||
Scheduler& scheduler_,
|
||||
GLContextMode contextMode_,
|
||||
const optional<std::string> programCacheDir_)
|
||||
const optional<std::string> programCacheDir_,
|
||||
const optional<std::string> localFontFamily_)
|
||||
: backend(backend_)
|
||||
, scheduler(scheduler_)
|
||||
, fileSource(fileSource_)
|
||||
@@ -50,7 +51,7 @@ Renderer::Impl::Impl(RendererBackend& backend_,
|
||||
, contextMode(contextMode_)
|
||||
, pixelRatio(pixelRatio_)
|
||||
, programCacheDir(programCacheDir_)
|
||||
, glyphManager(std::make_unique<GlyphManager>(fileSource))
|
||||
, glyphManager(std::make_unique<GlyphManager>(fileSource, std::make_unique<LocalGlyphRasterizer>(localFontFamily_)))
|
||||
, imageManager(std::make_unique<ImageManager>())
|
||||
, lineAtlas(std::make_unique<LineAtlas>(Size{ 256, 512 }))
|
||||
, imageImpls(makeMutable<std::vector<Immutable<style::Image::Impl>>>())
|
||||
|
||||
@@ -36,7 +36,7 @@ class Renderer::Impl : public GlyphManagerObserver,
|
||||
public RenderSourceObserver{
|
||||
public:
|
||||
Impl(RendererBackend&, float pixelRatio_, FileSource&, Scheduler&, GLContextMode,
|
||||
const optional<std::string> programCacheDir);
|
||||
const optional<std::string> programCacheDir, const optional<std::string> localFontFamily);
|
||||
~Impl() final;
|
||||
|
||||
void markContextLost() {
|
||||
|
||||
@@ -25,7 +25,7 @@ public:
|
||||
|
||||
class GlyphManager : public util::noncopyable {
|
||||
public:
|
||||
GlyphManager(FileSource&, std::unique_ptr<LocalGlyphRasterizer> = std::make_unique<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
|
||||
|
||||
@@ -32,11 +32,15 @@ namespace mbgl {
|
||||
|
||||
class LocalGlyphRasterizer {
|
||||
public:
|
||||
virtual ~LocalGlyphRasterizer() = default;
|
||||
virtual ~LocalGlyphRasterizer();
|
||||
LocalGlyphRasterizer(const optional<std::string> fontFamily = optional<std::string>());
|
||||
|
||||
// virtual so that test harness can override platform-specific behavior
|
||||
virtual bool canRasterizeGlyph(const FontStack&, GlyphID);
|
||||
virtual Glyph rasterizeGlyph(const FontStack&, GlyphID);
|
||||
private:
|
||||
class Impl;
|
||||
std::unique_ptr<Impl> impl;
|
||||
};
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -392,6 +392,11 @@ bool allowsIdeographicBreaking(char16_t chr) {
|
||||
// || isInCJKCompatibilityIdeographsSupplement(chr));
|
||||
}
|
||||
|
||||
bool allowsFixedWidthGlyphGeneration(char16_t chr) {
|
||||
// Mirrors conservative set of characters used in glyph_manager.js/_tinySDF
|
||||
return isInCJKUnifiedIdeographs(chr) || isInHangulSyllables(chr);
|
||||
}
|
||||
|
||||
bool allowsVerticalWritingMode(const std::u16string& string) {
|
||||
for (char32_t chr : string) {
|
||||
if (hasUprightVerticalOrientation(chr)) {
|
||||
|
||||
@@ -23,6 +23,10 @@ bool allowsIdeographicBreaking(const std::u16string& string);
|
||||
by the given Unicode codepoint due to ideographic breaking. */
|
||||
bool allowsIdeographicBreaking(char16_t chr);
|
||||
|
||||
/** Conservative set of characters expected to have relatively fixed sizes and
|
||||
advances */
|
||||
bool allowsFixedWidthGlyphGeneration(char16_t chr);
|
||||
|
||||
/** Returns whether any substring of the given string can be drawn as vertical
|
||||
text with upright glyphs. */
|
||||
bool allowsVerticalWritingMode(const std::u16string& string);
|
||||
|
||||
Reference in New Issue
Block a user