'use strict';

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

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.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.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)";
}

exports.drawGlyph = drawGlyph;
//# sourceMappingURL=drawGlyph.js.map
