<commit_before>//******************************************************************************
//
// Copyright (c) 2015 Microsoft Corporation. All rights reserved.
//
// This code is licensed under the MIT License (MIT).
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
//******************************************************************************

#include "Starboard.h"
#include <UIKit/UIKit.h>
#include "CGFontInternal.h"
#include "CoreGraphics/CGContext.h"
#include "Foundation/NSMutableDictionary.h"
#include <assert.h>

void NSStringForceinclude() {
    [NSString class];
}

NSString* const UITextAttributeFont = @"UITextAttributeFont";
NSString* const UITextAttributeTextColor = @"UITextAttributeTextColor";
NSString* const UITextAttributeTextShadowColor = @"UITextAttributeTextShadowColor";
NSString* const UITextAttributeTextShadowOffset = @"UITextAttributeTextShadowOffset";

@implementation NSString (UIKitAdditions)
static void drawCharsAtPoint(UIFont* font,
                             CGContextRef context,
                             WORD* str,
                             DWORD strLength,
                             CGRect rct,
                             float x,
                             float y,
                             UITextAlignment alignment,
                             CGSize* sizeOut) {
    float size = [font pointSize];
    CGFontFitChars(font, size, str, strLength, 0, sizeOut);
    // CGFontMeasureGlyphs(font, size, str, strLength, sizeOut);

    //  Calculate output position
    float outX, outY = y;

    switch (alignment) {
        case UITextAlignmentLeft:
            outX = rct.origin.x;
            break;

        case UITextAlignmentCenter:
            outX = rct.origin.x + (rct.size.width / 2.0f) - (sizeOut->width / 2.0f);
            break;

        case UITextAlignmentRight:
            outX = rct.origin.x + rct.size.width - sizeOut->width;<commit_msg>Partial fix for VSO 5795281: Move some UIText attribute names to NS.<commit_after>//******************************************************************************
//
// Copyright (c) 2015 Microsoft Corporation. All rights reserved.
//
// This code is licensed under the MIT License (MIT).
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
//******************************************************************************

#include "Starboard.h"
#include <UIKit/UIKit.h>
#include "CGFontInternal.h"
#include "CoreGraphics/CGContext.h"
#include "Foundation/NSMutableDictionary.h"
#include <assert.h>

void NSStringForceinclude() {
    [NSString class];
}

// Contingent upon VSO 5795281: All of these names need to be compatible with the reference platform.
NSString* const UITextAttributeFont = NSFontAttributeName;
NSString* const UITextAttributeTextColor = NSForegroundColorAttributeName;
NSString* const UITextAttributeTextShadowColor = @"UITextAttributeTextShadowColor";
NSString* const UITextAttributeTextShadowOffset = @"UITextAttributeTextShadowOffset";

@implementation NSString (UIKitAdditions)
static void drawCharsAtPoint(UIFont* font,
                             CGContextRef context,
                             WORD* str,
                             DWORD strLength,
                             CGRect rct,
                             float x,
                             float y,
                             UITextAlignment alignment,
                             CGSize* sizeOut) {
    float size = [font pointSize];
    CGFontFitChars(font, size, str, strLength, 0, sizeOut);
    // CGFontMeasureGlyphs(font, size, str, strLength, sizeOut);

    //  Calculate output position
    float outX, outY = y;

    switch (alignment) {
        case UITextAlignmentLeft:
            outX = rct.origin.x;
            break;

        case UITextAlignmentCenter:
            outX = rct.origin.x + (rct.size.width / 2.0f) - (sizeOut->width / 2.0f);
            break;

        case UITextAlignmentRight:
            outX = rct.origin.x + rct.size.width - sizeOut->width;
{'fraction_non_alphanumeric': 0.14353085913471397, 'fraction_numerical': 0.00656141070330121, 'mean_word_length': 2.681509433962264, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7375892', 'n_tokens_mistral': 1334, 'n_tokens_neox': 1203, 'n_words': 412}