terminal/src/types/GlyphWidth.cpp
Dustin Howett d4d59fa339 Initial release of the Windows Terminal source code
This commit introduces all of the Windows Terminal and Console Host source,
under the MIT license.
2019-05-02 15:29:04 -07:00

40 lines
1.3 KiB
C++

// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
#include "precomp.h"
#include "inc/CodepointWidthDetector.hpp"
#include "inc/GlyphWidth.hpp"
static CodepointWidthDetector widthDetector;
// Function Description:
// - determines if the glyph represented by the string of characters should be
// wide or not. See CodepointWidthDetector::IsWide
bool IsGlyphFullWidth(const std::wstring_view glyph)
{
return widthDetector.IsWide(glyph);
}
// Function Description:
// - determines if the glyph represented by the single character should be
// wide or not. See CodepointWidthDetector::IsWide
bool IsGlyphFullWidth(const wchar_t wch)
{
return widthDetector.IsWide(wch);
}
// Function Description:
// - Sets a function that should be used by the global CodepointWidthDetector
// as the fallback mechanism for determining a particular glyph's width,
// should the glyph be an ambiguous width.
// A Terminal could hook in a Renderer's IsGlyphWideByFont method as the
// fallback to ask the renderer for the glyph's width (for example).
// Arguments:
// - pfnFallback - the function to use as the fallback method.
// Return Value:
// - <none>
void SetGlyphWidthFallback(std::function<bool(const std::wstring_view)> pfnFallback)
{
widthDetector.SetFallbackMethod(pfnFallback);
}