apply formatting to file
This commit is contained in:
@@ -111,7 +111,7 @@ namespace OpenVulkano::Scene
|
||||
template<int Channels>
|
||||
void SdfFontAtlasGeneratorGeneric<Channels>::Generate(msdfgen::FreetypeHandle* ft, msdfgen::FontHandle* font,
|
||||
const msdf_atlas::Charset& chset,
|
||||
const std::optional<std::string>& pngOutput)
|
||||
const std::optional<std::string>& pngOutput)
|
||||
{
|
||||
std::vector<msdf_atlas::GlyphGeometry> glyphsGeometry;
|
||||
// FontGeometry is a helper class that loads a set of glyphs from a single font.
|
||||
@@ -122,7 +122,9 @@ namespace OpenVulkano::Scene
|
||||
{
|
||||
const double maxCornerAngle = 3.0;
|
||||
for (msdf_atlas::GlyphGeometry& glyph : glyphsGeometry)
|
||||
{
|
||||
glyph.edgeColoring(&msdfgen::edgeColoringByDistance, maxCornerAngle, 0);
|
||||
}
|
||||
}
|
||||
|
||||
msdf_atlas::TightAtlasPacker packer;
|
||||
@@ -147,8 +149,10 @@ namespace OpenVulkano::Scene
|
||||
generator.generate(glyphsGeometry.data(), glyphsGeometry.size());
|
||||
|
||||
int idx = 0;
|
||||
m_atlasData = std::make_shared<FontAtlas>(Math::Vector2ui{ width, height }, fontGeometry.getMetrics().lineHeight,
|
||||
channelsCount == 1 ? FontAtlasType::SDF : FontAtlasType::MSDF, m_channelsCount == 1 ? DataFormat::R8_UNORM : DataFormat::R8G8B8A8_UNORM);
|
||||
m_atlasData =
|
||||
std::make_shared<FontAtlas>(Math::Vector2ui { width, height }, fontGeometry.getMetrics().lineHeight,
|
||||
channelsCount == 1 ? FontAtlasType::SDF : FontAtlasType::MSDF,
|
||||
m_channelsCount == 1 ? DataFormat::R8_UNORM : DataFormat::R8G8B8A8_UNORM);
|
||||
|
||||
if constexpr (Channels == 3)
|
||||
{
|
||||
@@ -164,7 +168,7 @@ namespace OpenVulkano::Scene
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
const msdfgen::BitmapConstRef<msdfgen::byte, 1>& storage = generator.atlasStorage();
|
||||
memcpy(m_atlasData->GetTexture()->textureBuffer, storage.pixels, width * height);
|
||||
}
|
||||
@@ -174,7 +178,7 @@ namespace OpenVulkano::Scene
|
||||
double l = 0, r = 0, t = 0, b = 0;
|
||||
};
|
||||
|
||||
for (const auto& glyph: glyphsGeometry)
|
||||
for (const auto& glyph : glyphsGeometry)
|
||||
{
|
||||
GlyphInfo& info = m_atlasData->GetGlyphs()[glyph.getCodepoint()];
|
||||
const msdf_atlas::GlyphBox& glyphBox = generator.getLayout()[idx++];
|
||||
@@ -187,6 +191,8 @@ namespace OpenVulkano::Scene
|
||||
double bearingY = glyphBox.bounds.t;
|
||||
double w = glyphBaselineBbox.r - glyphBaselineBbox.l;
|
||||
double h = glyphBaselineBbox.t - glyphBaselineBbox.b;
|
||||
|
||||
// UV mapping
|
||||
double l = glyphAtlasBbox.l;
|
||||
double r = glyphAtlasBbox.r;
|
||||
double t = glyphAtlasBbox.t;
|
||||
@@ -200,7 +206,10 @@ namespace OpenVulkano::Scene
|
||||
SetGlyphData(info, { bearingX, bearingY }, { w, h }, glyphAtlasAABB, glyphBox.advance);
|
||||
}
|
||||
|
||||
if (pngOutput && !pngOutput->empty()) { m_atlasData->Save(*pngOutput); }
|
||||
if (pngOutput && !pngOutput->empty())
|
||||
{
|
||||
m_atlasData->Save(*pngOutput);
|
||||
}
|
||||
destroyFont(font);
|
||||
deinitializeFreetype(ft);
|
||||
}
|
||||
@@ -208,4 +217,4 @@ namespace OpenVulkano::Scene
|
||||
template class SdfFontAtlasGeneratorGeneric<1>;
|
||||
template class SdfFontAtlasGeneratorGeneric<3>;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user