import '../../core/settings.mjs';
import { Color } from '../../color.mjs';
import '../../constants.mjs';
import '../../extensions.mjs';
import '../../math/const.mjs';
import '../../math/groupD8.mjs';
import '../../math/Transform.mjs';
import '../../runner.mjs';
import '../../ticker/settings.mjs';
import '../../ticker/const.mjs';
import '../../ticker/Ticker.mjs';
import '../../ticker/TickerPlugin.mjs';
import '../../utils/settings.mjs';
import '../../utils/is_mobile/index.mjs';
import '../../utils/color/premultiply.mjs';
import '../../utils/media/BoundingBox.mjs';
import '../../core/autoDetectRenderer.mjs';
import '../../core/background/BackgroundSystem.mjs';
import '../../core/batch/BatchRenderer.mjs';
import '../../core/shader/Program.mjs';
import '../../core/batch/BatchSystem.mjs';
import '../../core/context/ContextSystem.mjs';
import '../../core/filters/Filter.mjs';
import '../../core/filters/FilterSystem.mjs';
import '../../core/textures/BaseTexture.mjs';
import '../../core/framebuffer/FramebufferSystem.mjs';
import '../../core/framebuffer/MultisampleSystem.mjs';
import '../../core/geometry/BufferSystem.mjs';
import '../../core/geometry/GeometrySystem.mjs';
import '../../core/mask/MaskSystem.mjs';
import '../../core/mask/ScissorSystem.mjs';
import '../../core/mask/StencilSystem.mjs';
import '../../core/plugin/PluginSystem.mjs';
import '../../core/projection/ProjectionSystem.mjs';
import '../../core/render/ObjectRendererSystem.mjs';
import '../../core/Renderer.mjs';
import '../../core/renderTexture/GenerateTextureSystem.mjs';
import '../../core/renderTexture/RenderTexturePool.mjs';
import '../../core/renderTexture/RenderTextureSystem.mjs';
import '../../core/shader/ShaderSystem.mjs';
import '../../core/startup/StartupSystem.mjs';
import '../../core/state/StateSystem.mjs';
import '../../core/textures/TextureGCSystem.mjs';
import '../../core/textures/TextureSystem.mjs';
import '../../core/transformFeedback/TransformFeedbackSystem.mjs';
import '../../core/view/ViewSystem.mjs';
import '../../core/textures/resources/index.mjs';
import { generateFillStyle } from './generateFillStyle.mjs';

function drawGlyph(canvas, context, metrics, x, y, resolution, style) {
  const char = metrics.text;
  const fontProperties = metrics.fontProperties;
  context.translate(x, y);
  context.scale(resolution, resolution);
  const tx = style.strokeThickness / 2;
  const ty = -(style.strokeThickness / 2);
  context.font = style.toFontString();
  context.lineWidth = style.strokeThickness;
  context.textBaseline = style.textBaseline;
  context.lineJoin = style.lineJoin;
  context.miterLimit = style.miterLimit;
  context.fillStyle = generateFillStyle(canvas, context, style, resolution, [char], metrics);
  context.strokeStyle = style.stroke;
  if (style.dropShadow) {
    const dropShadowColor = style.dropShadowColor;
    const dropShadowBlur = style.dropShadowBlur * resolution;
    const dropShadowDistance = style.dropShadowDistance * resolution;
    context.shadowColor = Color.shared.setValue(dropShadowColor).setAlpha(style.dropShadowAlpha).toRgbaString();
    context.shadowBlur = dropShadowBlur;
    context.shadowOffsetX = Math.cos(style.dropShadowAngle) * dropShadowDistance;
    context.shadowOffsetY = Math.sin(style.dropShadowAngle) * dropShadowDistance;
  } else {
    context.shadowColor = "black";
    context.shadowBlur = 0;
    context.shadowOffsetX = 0;
    context.shadowOffsetY = 0;
  }
  if (style.stroke && style.strokeThickness) {
    context.strokeText(char, tx, ty + metrics.lineHeight - fontProperties.descent);
  }
  if (style.fill) {
    context.fillText(char, tx, ty + metrics.lineHeight - fontProperties.descent);
  }
  context.setTransform(1, 0, 0, 1, 0, 0);
  context.fillStyle = "rgba(0, 0, 0, 0)";
}

export { drawGlyph };
//# sourceMappingURL=drawGlyph.mjs.map
